//
//  messageHeaderView.m
//  SoundPill
//
//  Created by 宋旭东 on 16/4/22.
//  Copyright © 2016年 宋旭东. All rights reserved.
//

#import "messageHeaderView.h"
#import "UIViewExt.h"
#define kleftGap  10
#define kupGap   12
#define kDeviceWidth [UIScreen mainScreen].bounds.size.width
#define kImageViewWidth 40
#define kImageViewHeight 40
#define kLabelWidth [UIScreen mainScreen].bounds.size.width*0.35
#define kLabelHeight 60
@implementation messageHeaderView
- (instancetype)initWithFrame:(CGRect)frame withCount:(NSInteger)count
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews:count];
        self.userInteractionEnabled = YES;
    }
    return self;
}
- (void)createSubviews:(NSInteger)Count
{
    UIImageView *avatar = [[UIImageView alloc] initWithFrame:CGRectMake(kleftGap, kupGap, self.height - (2 * kupGap), self.height - (2 * kupGap))];
    avatar.image = [UIImage imageNamed:@"bigLogo"];
    [self addSubview:avatar];
    
    UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(avatar.right + 10, avatar.top, self.frame.size.width - (avatar.right + 20), avatar.height / 2)];
    name.font = [UIFont fontWithName:@"Helvetica-Bold" size:15.0f];
    name.textColor = [UIColor blackColor];
    name.text = @"系统消息";
    [self addSubview:name];
    self.countLabel = [[UILabel alloc] initWithFrame:CGRectMake(avatar.right + 10,name.bottom + 5,(self.frame.size.width - (avatar.right + 10)) / 2, 16)];
    _countLabel.font = [UIFont systemFontOfSize:14];
    if (Count  > 0) {
        _countLabel.text = [NSString stringWithFormat:@"你有 %ld 条新消息",(long)Count];
        _countLabel.textColor = [UIColor blackColor];
    } else {
        _countLabel.text = @"你有 0 条新消息";
        _countLabel.textColor = [UIColor grayColor];
    }
    [self addSubview:_countLabel];
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, self.height, self.width, 0.5)];
    line.backgroundColor = [UIColor colorWithRed:0.895 green:0.898 blue:0.908 alpha:1.000];
    [self addSubview:line];
}
@end
